home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 September / macformat-004.iso / Shareware City / Developers / Mac F2C 1.0 / For non THINK v7 Users < prev    next >
Encoding:
Text File  |  1994-06-11  |  11.5 KB  |  302 lines  |  [TEXT/ttxt]

  1.  
  2. This file provides instructions on how to build the required support 
  3. libraries if you are not using THINK version 7.0 or later.  It also 
  4. includes some general guidance for users of other compilers (e.g., 
  5. CodeWarrior or MPW), but because I do not own either of these I can only 
  6. provide general guidance.
  7.  
  8.  
  9.  
  10. CONTENTS
  11. ********
  12.  
  13.     A.  BUILDING THE SUPPORT LIBRARIES USING THINK C
  14.     
  15.     B.  CONVERTING THE TEST PROJECT
  16.     
  17.     C.  HOW TO USE THE MODEL PROJECT
  18.     
  19.     D.  IF YOU USE COMPILERS OTHER THAN THINK C
  20.     
  21.     
  22.     
  23. A.  BUILDING THE SUPPORT LIBRARIES USING THINK C
  24. *************************************************
  25.  
  26. There are five support libraries required to run programs translated by 
  27. Mac F2C.  These libraries are:
  28.  
  29.     (1) ANSI F2C
  30.     (2) unix F2C
  31.     (3) libI77a
  32.     (4) libI77b
  33.     (5) libF77
  34.     
  35. You should first install these as specified in the "READ ME" file.  The 
  36. first two libraries belong in the "Standard Libraries" folder; the second 
  37. three belong in the "Mac F2C Libraries" folder which you should place in 
  38. the folder that contains the THINK Project Manager (or the THINK C 
  39. application for versions prior to version 6).  
  40.  
  41. TO MAKE "ANSI F2C" AND "unix F2C"
  42.  
  43. Delete "ANSI F2C" and "unix F2C" provided with Mac F2C.  Duplicate the 
  44. "ANSI" and "unix" libraries in the "Standard Libraries" folder (the ones 
  45. provided by Symantec).  Rename the duplicates "ANSI F2C" and "unix F2C".  
  46. Open each one and do the following:
  47.  
  48.     (a) Remove objects
  49.     
  50.     (b) In the "Options" dialog select:
  51.         - 4-byte integers
  52.         - 2-byte doubles
  53.         - native floating-point format (if producing C++ vice C code)
  54.         - 68020 code generation (strongly recommended, not required)
  55.  
  56.     (c) In the "Set Project Type" dialog select:
  57.         - Far code
  58.         - Far data
  59.  
  60.     (d) Bring Up To Date
  61.     
  62.  
  63. TO MAKE "libI77a", "libI77b", AND "libF77"
  64.  
  65. In the "Mac F2C Libraries" folder you will find these three libraries, 
  66. corresponding files called "Contents of xxx", and two folders of source 
  67. code ("libI77 Sources" and "libF77 Sources").  The files "Contents of 
  68. xxx" contain detailed descriptions of the what each library contains.  
  69.  
  70. The process is the same for all three libraries.  I will illustrate it 
  71. with "libI77a":
  72.  
  73.     (a) Delete "libI77a"
  74.     
  75.     (b) Create a new empty project called "libI77a"
  76.  
  77.     (c) In the "Options" dialog select:
  78.         - 4-byte integers
  79.         - 2-byte doubles
  80.         - native floating-point format (if producing C++ vice C code)
  81.         - 68020 code generation (strongly recommended, not required)
  82.         - #define MACINTOSH
  83.         - #define NON_UNIX_STDIO (for "libI77a" and "libI77b" only)
  84.         - #define _POSIX_SOURCE  (for "libI77a" and "libI77b" only)
  85.  
  86.     (d) In the "Set Project Type" dialog select:
  87.         - Far code
  88.         - Far data
  89.         
  90.     (e) Open the text file "Contents of libI77a"
  91.  
  92.     (f) Add source files from the folder "libI77 Sources" as required to match 
  93.         the list that appears in "Contents of libI77a"
  94.         
  95.     (g) Bring the project up to date
  96.     
  97. Repeat this process with "libI77b" and "libF77".  "libF77" contains over 
  98. one hundred files.  You may find it easier to include all the source files 
  99. in the folder "libF77 Sources" initially and then remove the handful that 
  100. don't belong in "libF77".
  101.  
  102.  
  103.  
  104. B.  CONVERTING THE TEST PROJECT
  105. *******************************
  106.  
  107. The folder "Test Project ƒ" contains a project file called "Test 
  108. Project.π" and a text file called "Contents of Test Project.π".  This 
  109. file describes in detail the contents of the test project.  To create a 
  110. version compatible with your version of THINK C, do the following:
  111.  
  112.     (a) Delete "Test Project.π"
  113.     
  114.     (b) Create a new empty project called "Test Project.π"
  115.  
  116.     (c) In the "Options" dialog select:
  117.         - 4-byte integers
  118.         - 2-byte doubles
  119.         - native floating-point format (if selected for the libraries)
  120.         - 68020 code generation (strongly recommended, not required)
  121.         - #define MACINTOSH
  122.  
  123.     (d) In the "Set Project Type" dialog select:
  124.         - Far code
  125.         - Far data
  126.         
  127.     (e) Open the text file "Contents of Test Project.π"
  128.  
  129.     (f) Add sources and libraries as required to match the list that appears 
  130.         in "Contents of Test Project.π" (You will not be able to add "Test.c" 
  131.         until you create it by translating "Test.f" with Mac F2C)
  132.         
  133.     (f) Segment the project as indicated in "Contents of Test Project.π" (in some 
  134.         versions of THINK C you cannot name the segments; this is not a 
  135.         problem, just ignore the segment names).
  136.  
  137.  
  138.  
  139. C.  HOW TO USE THE MODEL PROJECT
  140. ********************************
  141.  
  142. The project model is the folder "Mac F2C Project" which is located in the 
  143. folder "For '(Project Models)'".  The folder "Mac F2C Project" contains 
  144. the following files:
  145.  
  146.     (1) "@1.π" -- a THINK C version 7.0 project file.
  147.     
  148.     (2) "main.c" -- a driver program required to run programs compiled by 
  149.                     Mac F2C.
  150.                     
  151.     (3) "f2c.h" -- a header file required by code compiled by Mac F2C.
  152.     
  153.     (4) "Contents of @1.π" -- a text file listing the contents of "@1.π"
  154.     
  155. This what you need to compile, link, and run files produced by Mac F2C.  
  156. In THINK C version 7.0 or later, the THINK project manager automatically 
  157. makes a copy of the entire model project (i.e., the entire "Mac F2C 
  158. Project" folder) and renames the folder and project file when you create 
  159. a new project using this model.  To use the project model with versions 
  160. of THINK C prior to 7.0, you will need to:
  161.     
  162.     (a) replace "@1.π" which a project compatible with your version of 
  163.         THINK C
  164.     
  165.     (b) everytime you want to create a new project for Mac F2C code, 
  166.         duplicate the project model folder by hand and rename the folder 
  167.         and project file by hand.
  168.         
  169. To create a version of "@1.π" compatible with your version of THINK C, do 
  170. the following:
  171.  
  172.     (a) Delete "@1.π"
  173.     
  174.     (b) Create a new empty project called "@1.π"
  175.  
  176.     (c) In the "Options" dialog select:
  177.         - 4-byte integers
  178.         - 2-byte doubles
  179.         - native floating-point format (if producing C++ vice C code)
  180.         - 68020 code generation (strongly recommended, not required)
  181.         - #define MACINTOSH
  182.  
  183.     (d) In the "Set Project Type" dialog select:
  184.         - Far code
  185.         - Far data
  186.         
  187.     (e) Open the text file "Contents of @1.π"
  188.  
  189.     (f) Add sources and libraries as required to match the list that appears 
  190.         in "Contents of @1.π"
  191.         
  192.     (g) Segment the project as indicated in "Contents of @1.π" (in some 
  193.         versions of THINK C you cannot name the segments; this is not a problem).
  194.  
  195.  
  196.  
  197. D.  IF YOU USE COMPILERS OTHER THAN THINK C
  198. *******************************************
  199.  
  200. If you use a compiler other than THINK C, you will have to make libraries 
  201. on your own and you will almost certainly have to make some minor 
  202. modifications to some of the source files in the support libraries.
  203.  
  204. You can use the "Contents of xxx" files in the "Mac F2C Libraries" folder 
  205. to figure out what to put in each library.  If your compiler/linker 
  206. allows libraries larger than 32K, you can combine "libI77a" and "libI77b" 
  207. into a single library.  You could also combine all three ("libI77a", 
  208. "libI77b", and "libF77") into a single library if you so desire.
  209.  
  210. Make sure to compile the libraries so that integers are 4-bytes, doubles 
  211. are 8-bytes, and you can have more than 32K of static/global data and 
  212. jump tables larger than 32K.  See the section on Using Code Produced by 
  213. Mac F2C in the "READ ME" file for more information on these requirements 
  214. and when they can be relaxed.
  215.  
  216. You must also #define the following things when compiling these files:
  217.  
  218. For "libF77"
  219.  
  220.     #define MACINTOSH               -- turn on Macintosh specific changes
  221.     
  222. For "libI77a" and "libI77b" 
  223.  
  224.     #define MACINTOSH               -- turn on Macintosh specific changes
  225.     #define NON_UNIX_STDIO            -- force the use of ANSI standard I/O
  226.     #define _POSIX_SOURCE        -- force the use of mktemp() functions
  227.  
  228. Most of the files in the Mac F2C support libraries compile without 
  229. trouble on Macintoshes.  Nevertheless, I had to modify a few files, 
  230. and in doing so I sometimes had to rely on features specific to THINK 
  231. C.  The files in question are:
  232.  
  233. In "libI77"
  234.  
  235.     access.c        This function returns 0 if file called fileName 
  236.                          exists, 1 otherwise.  I had to write this from 
  237.                          scratch and I used a function from the THINK C 
  238.                          unix library to do it.  You will probably have to 
  239.                          re-write this function.  (Yes, I could have used a 
  240.                          Macintosh Toolbox call, but I was lazy…)
  241.     
  242. In "libF77"
  243.  
  244.     erf_fctns.c    THINK C does not provide error functions in their 
  245.                          library.  I wrote my own.  They have decent numeric 
  246.                          properties and will compile with any ANSI C compiler.   
  247.                          You may wish to replace it with (perhaps faster) 
  248.                          vendor provided error functions.
  249.     
  250.     getenv_.c      I had to write my own.  I wrote one that returns a 
  251.                          blank environment string.  Modify as appropriate for 
  252.                          your compiler.
  253.  
  254.     getpid.c        I had to write my own.  I exploited a global variable 
  255.                         that is defined and maintained by the THINK C unix 
  256.                         library.  You will have to modify this file to work 
  257.                         with your system.  If all else fails, return 0.
  258.  
  259.  
  260. Code produced by Mac F2C also relies on the THINK C ANSI and unix 
  261. libraries.  The THINK C ANSI library is exactly what it says it is.  Your 
  262. compiler should include such a library.  The THINK C unix library provides 
  263. a large collection of functions commonly available on unix systems.  Your 
  264. compiler may or may not include such a library.  If it doesn't, you will 
  265. get link errors when compiling programs produced by Mac F2C.  You will have 
  266. to provide the missing functions yourself.  It's actually not hard to do, 
  267. especially because in many cases you only need a place holder function 
  268. (e.g., see "getenv_.c" or "getpid.c").  When a placeholder isn't enough, 
  269. you can figure what the function needs to do by checking a unix manual or 
  270. using the "man" command on a unix system.
  271.  
  272. In any case make sure your versions of the ANSI and unix libraries are 
  273. compiled with the proper options (4-byte integers, 8-byte doubles, jump 
  274. tables larger than 32K, global data larger than 32K, and any C++ 
  275. compatibility options if you plan to ever produce C++ code as Mac F2C 
  276. output).
  277.  
  278. Finally, to run a program translated by Mac F2C, you need to link the 
  279. following things together (this is automatically set up for THINK C users 
  280. by the model project:
  281.  
  282.     -   your translated code
  283.     -   "main.c"
  284.     -   libI77a
  285.     -   libI77b
  286.     -   libF77
  287.     -   ANSI
  288.     -   unix
  289.     
  290. The file "main.c" is a driver that sets up a bunch of things and then calls 
  291. the translated version of the FORTRAN main program.  I modified "main.c" to 
  292. use the THINK C console interface.  In particular, "main.c" calls the 
  293. function ccommand() to get command-line arguments from the user.  You will 
  294. need to modify this accordingly for your compiler.
  295.  
  296. Good luck.  If you have any questions, feel free to email me at 
  297. igormt@alumni.caltech.edu.  If you make a stable, general purpose port of 
  298. the libraries and/or "main.c" to another Macintosh compiler, send me a copy 
  299. and I will include it in future distributions of Mac F2C (with full credit 
  300. and much gratitude).
  301.                     
  302.